package edu.gatech.cs2340.spring2012.team38;

import edu.gatech.cs2340.spring2012.team38.database.UserDBHelper;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class TigerShroudActivity extends Activity {
	private DatabaseHelper dBHelp;
  
	/** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        dBHelp = new DatabaseHelper(this);
        dBHelp.open();
        
        final Button button1 = (Button) findViewById(R.id.loginbutton);
        final EditText txtfield1 = (EditText) findViewById(R.id.editText1);
        final EditText txtfield2 = (EditText) findViewById(R.id.editText2);
     
        button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	/*Still does not work properly*/
        	if (dBHelp.lookupUser(txtfield1.getText().toString()).equals
        			(txtfield1.getText().toString())) {
        	    Intent goToNextActivity = new Intent(getApplicationContext(), 
        	    	LoginActivity.class);
        	    startActivity(goToNextActivity);
        	}
        	
  
        }
        });
        
        final Button button2 = (Button) findViewById(R.id.button1);
        button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        	String user = txtfield1.getText().toString();
    		String pass = txtfield2.getText().toString();
    		//dBHelp.insertUser("user", "pass");
    		//txtfield1.setText(dBHelp.lookupUser("user"));
        	/*Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
        	startActivity(intent); */       	
            }
        });

        
    }
}